package br.com.vexillum.model;

import java.io.Serializable;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import br.com.vexillum.model.annotations.SearchField;

/**
 * @author Pedro Henrique, Entidade master todas as classes
 * de negócio herdam dela
 *
 */
@SuppressWarnings({ "serial" })
@MappedSuperclass
public abstract class CommonEntity implements Serializable {

	@SearchField
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)     
	protected Long id;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@Override
	public boolean equals(Object obj){
		if(this == obj)
			return true;
		if(obj == null)
			return false;
		CommonEntity entity = (CommonEntity) obj;
		if(getId() == 0){
			if(entity.getId() != 0){
				return false;
			}
		} else if(getId() != entity.getId()){
			return false;
		}
		return true;
	}

}
